package com.hmall.order.web;

import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.ReqParams;
import com.hmall.order.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      log.info("根据订单id {} 查询订单", orderId);
      return orderService.getById(orderId);
   }

   /**
    * 提交订单
    * @param reqParams
    * @return 订单id
    */
   @PostMapping
   public Long submitOrder(@RequestBody ReqParams reqParams) {
      log.info("提交订单：{}",reqParams);
      return orderService.submitOrder(reqParams);
   }
}
